/*******************************************************************************
*  file    : networkdataprovider.hpp
*  created : 19.08.2014
*  author  : Slyshyk Oleksiy (alexSlyshyk@gmail.com)
*******************************************************************************/

#ifndef NETWORKDATAPROVIDER_HPP
#define NETWORKDATAPROVIDER_HPP

#include "dataprovider.hpp"
#include <QHostAddress>

class QTcpSocket;

class NetworkDataProvider : public DataProvider
{
    Q_OBJECT
public:
    explicit NetworkDataProvider(QObject *parent = 0);
    QString  name() const;
    bool connectToHost(const QHostAddress & address, quint16 port = 5555);
private slots:
    void onDataReady();
    void onSockError(QAbstractSocket::SocketError socketError);
    void reconnect();
private:
    QTcpSocket* socket_ = nullptr;
    QByteArray  buff_;
    QStringList strings_;

    quint16      port_ = 5555;
    QHostAddress addr_;
};

#endif // NETWORKDATAPROVIDER_HPP
